package com.erp.myAdapter

import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.erp.bean.JiaFangBean
import com.erp.R
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_jiafang.view.*

/**
 * Created by Administrator on 2018/6/22/022.
 * 作者：刘洋
 */
class JiaFangAdapter(val context : Context, val mlist: MutableList<JiaFangBean>)  : BaseAdapter(){
    var minflater: LayoutInflater = LayoutInflater.from(context)
    override fun getItem(position: Int): Any {
        return mlist[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getCount(): Int {
        return mlist.size
    }
    @SuppressLint("InflateParams")
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v :View
        var h : ViewHolder
        if(convertView==null){
            v = minflater.inflate(R.layout.lv_jiafang,null)
            h = ViewHolder(v)
            v.tag=h
        }else{
            v = convertView
            h = v.tag as ViewHolder
        }
        var bean = mlist[position]
        if(bean.iioo_type=="-1"){
            h.TvLeiXing.text="出仓"
        }else if(bean.iioo_type=="1"){
            h.TvLeiXing.text="入仓"
        }
        Myutil.settv(bean.inum,h.TvDanHao)
        Myutil.settv(bean.code,h.TvBianMa)
        Myutil.settv(bean.iw_name,h.TvCangKu)
        Myutil.settv(bean.o_onum,h.TvShengchanDanhao)
        Myutil.settv(bean.name,h.TvMingcheng)
        Myutil.settv(bean.amount,h.TvShuliang)
        Myutil.settv(bean.size,h.TvGuiGe)
        Myutil.settv(bean.auditor_name,h.TvShenHeName)
        Myutil.settv(Myutil.getdata(bean.audit_time),h.TvShenHeTime)
        return v
    }
    class ViewHolder(var v : View){
        var TvDanHao = v.TvDanHao
        val TvLeiXing = v.TvLeiXing
        val TvBianMa = v.TvBianMa
        val TvCangKu = v.TvCangKu
        val TvShengchanDanhao = v.TvShengchanDanhao
        val TvGuiGe = v.TvGuiGe
        val TvMingcheng = v.TvMingcheng
        val TvShuliang = v.TvShuliang
        val TvShenHeName = v.TvShenHeName
        val TvShenHeTime = v.TvShenHeTime
    }
}